#include "cute.h"
#include "ide_listener.h"
#include "cute_runner.h"

#include "PCRTest.h"
#include "TableTest.h"
#include "SATest.h"
#include "SRTest.h"
#include "SPTest.h"
#include "CircBuffTest.h"

int main(int argc, char *argv[])
{
	int i = 0;

	char RTested = 0;
	cute::suite r;

	r.push_back(CUTE(PCRTest_PCR64ToPCR32Conversions));
	r.push_back(CUTE(PCRTest_PCRToPCR32Conversions));
	r.push_back(CUTE(PCRTest_PCRToPCR64Conversions));

	char STested = 0;
	cute::suite s;

	s.push_back(CUTE(TableTest_PATInit));
	s.push_back(CUTE(TableTest_PMTInit));
	s.push_back(CUTE(TableTest_TSInit));

	char TTested = 0;
	cute::suite t;

	t.push_back(CUTE(SATest_CreateDelete));
	t.push_back(CUTE(SATest_PushStream));

	char UTested = 0;
	cute::suite u;

	u.push_back(CUTE(CircBuffTest_CreateDelete));
	u.push_back(CUTE(CircBuffTest_ReadWrite));
	u.push_back(CUTE(CircBuffTest_FullnessEmptyness));
	u.push_back(CUTE(CircBuffTest_ReadNoCopy));
	u.push_back(CUTE(CircBuffTest_Watch));
	u.push_back(CUTE(CircBuffTest_ReadWriteOtherEltSize));
	u.push_back(CUTE(CircBuffTest_WaitRead));
	u.push_back(CUTE(CircBuffTest_WaitWrite));

	char VTested = 0;
	cute::suite v;

	v.push_back(CUTE(SRTest_CreateDeleteUdp));
	v.push_back(CUTE(SRTest_CreateDeleteTcp));
	v.push_back(CUTE(SRTest_CreateDeleteFile));
	v.push_back(CUTE(SRTest_ReceiveUdp));
	v.push_back(CUTE(SRTest_ReceiveTcp));
	v.push_back(CUTE(SRTest_ReadFile));

	char WTested = 0;
	cute::suite w;

	w.push_back(CUTE(SPTest_CreateDeleteUdp));
	w.push_back(CUTE(SPTest_CreateDeleteFile));
	w.push_back(CUTE(SPTest_DumpFile));
	w.push_back(CUTE(SPTest_SendUDP));


	// run the test
	cute::ide_listener lis;

	if (argc > 1)
	{
		for (i=0; i<argc; i++)
		{
			if ((strcmp(argv[i], "pcr") == 0) && (RTested == 0))
			{
				cute::makeRunner(lis)(r, "pcr tests");
				RTested = 1;
			}

			if ((strcmp(argv[i], "table") == 0) && (STested == 0))
			{
				cute::makeRunner(lis)(s, "table tests");
				STested = 1;
			}

			if ((strcmp(argv[i], "circb") == 0) && (UTested == 0))
			{
				cute::makeRunner(lis)(u, "CircBuff tests");
				UTested = 1;
			}

			if ((strcmp(argv[i], "sa") == 0) && (TTested == 0))
			{
				cute::makeRunner(lis)(t, "SA tests");
				TTested = 1;
			}

			if ((strcmp(argv[i], "sr") == 0) && (VTested == 0))
			{
				cute::makeRunner(lis)(v, "SR tests");
				VTested = 1;
			}

			if ((strcmp(argv[i], "sp") == 0) && (WTested == 0))
			{
				cute::makeRunner(lis)(w, "SP tests");
				WTested = 1;
			}
		}
	}
	else
	{
		cute::makeRunner(lis)(r, "pcr tests");
		cute::makeRunner(lis)(s, "Table tests");
		cute::makeRunner(lis)(u, "CircBuff tests");
		cute::makeRunner(lis)(t, "SA tests");
		cute::makeRunner(lis)(v, "SR tests");
		cute::makeRunner(lis)(w, "SP tests");
	}

	return 0;
}




